<template>
	<el-dialog v-model="props.visible" title="历史数据" width="80%" :before-close="close">
		<div>
			<Table
				:tableConfig="tableConfig"
				:tableColumns="tableColumns"
				:searchData="{
					businessKey: props.businessKey,
					businessType: props.businessType,
				}"
			>
				<template #operation>
					<el-table-column fixed="right" label="操作" width="180">
						<template #default="{ row }">
							<el-button class="mr-5" text type="primary" icon="View" @click="handleView(row)">查看</el-button>
						</template>
					</el-table-column>
				</template>
			</Table>
		</div>
		<template #footer>
			<div class="dialog-footer">
				<el-button @click="close">关闭</el-button>
			</div>
		</template>
	</el-dialog>
</template>

<script setup lang="ts">
import Table from '/@/components/HyTable/components/Table/index.vue';
import { threeListRecordsPageApi } from '/@/api/threeList/declare';

const props = defineProps({
	visible: Boolean,
	businessKey: {
		type: String,
		default: '',
	},
	//1  三张清单 2 应用申报
	businessType: {
		type: String,
		default: '1',
	},
});

const emits = defineEmits(['close']);
const close = () => {
	emits('close');
};
const tableConfig: any = {
	request: threeListRecordsPageApi,
};

const router = useRouter();

const handleView = (row: any) => {
	if (props.businessType === '1') {
		router.push({
			path: '/threeList/declare',
			query: {
				operateType: 'history',
				threeListId: row.historyVersionId,
			},
		});
	}
	if (props.businessType === '2') {
		router.push({
			path: '/digitalList/detail/demandDeclaration',
			query: {
				title: '数字化应用申报审核',
				id: row.historyVersionId,
				history: 'yes',
			},
		});
	}
};

const tableColumns = [{ prop: 'createTime', label: '创建时间' }];
</script>

<style scoped lang="scss"></style>
